package com.example.demo.interceptorToken;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author hulei
 * @date 2024/1/11 19:48
 * 将拦截注入spring容器
 */
@Configuration
public class InterceptorRegister implements WebMvcConfigurer {

    @Bean
    public RequestInterceptor tokenInterceptor() {
        return new RequestInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor());
    }
}